1739A - Immobile Knight - CodeForces Solution


implementation

Please click on ads to support us..

Python Code:

t = int(input())
for _ in range(t):
    n,m = map(int,input().split())
    if n == 1 or m == 1:
        print(n,m)
    elif n > 3 or m > 3:
        print(n,m)
    else:
        print(n-1,m-1)
        

C++ Code:

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl "\n"
#define intt __int128_t
#define all(a) a.begin(), a.end()
#define pb(a) push_back(a)
#define x first
#define y second
#define heap priority_queue

int main() {
    fast_cin();
    
    int t;
    cin >> t;
    
    while(t--){
    	int n, m;
    	cin >> n >> m;
    	
    	if (n == 3 && m == 3){
    		cout << "2 2" << endl;
		} else if ((n == 3 && m < 3)){
			cout << "2 1" << endl;
		} else if ((n < 3 && m == 3)) {
			cout << "1 2" << endl;
		}
		else {
			cout << "1 1"<< endl;
		}
    	
    	
	}
	
    return 0;
}










Comments

Submit
0 Comments
More Questions

1335A - Candies and Two Sisters
96B - Lucky Numbers (easy)
1151B - Dima and a Bad XOR
1435B - A New Technique
1633A - Div 7
268A - Games
1062B - Math
1294C - Product of Three Numbers
749A - Bachgold Problem
1486B - Eastern Exhibition
1363A - Odd Selection
131B - Opposites Attract
490C - Hacking Cypher
158B - Taxi
41C - Email address
1373D - Maximum Sum on Even Positions
1574C - Slay the Dragon
621A - Wet Shark and Odd and Even
1395A - Boboniu Likes to Color Balls
1637C - Andrew and Stones
1334B - Middle Class
260C - Balls and Boxes
1554A - Cherry
11B - Jumping Jack
716A - Crazy Computer
644A - Parliament of Berland
1657C - Bracket Sequence Deletion
1657B - XY Sequence
1009A - Game Shopping
1657A - Integer Moves